<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>生命周期</title>
</head>
<body>
    <!-- 引出生命周期 -->
    <div id="app">
        <h1 :style="{opacity}">{{title}}</h1>
    </div>
    <script>
        Vue.config.productionTip = false // 关闭开发模式警告
        const vm = new Vue({
            data(){
                return {
                    title:'Vue2生命周期',
                    opacity:1,
                }
            },
            mounted() {
                this.setOpactity()
            },
            methods: {
                setOpactity(){
                    setInterval(()=>{
                        this.opacity-=0.01
                        if(this.opacity<=0) 
                            this.opacity = 1
                    },16)
                }
            },
        }).$mount('#app')
    </script>
</body>
</html>